// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
// import com.alibaba.druid.sql.dialect.mysql.ast.MySqlObjectImpl;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;

#include "MySqlOutFileExpr.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../ast/expr/SQLLiteralExpr.h"

MySqlOutFileExpr::MySqlOutFileExpr()
{
}

MySqlOutFileExpr::MySqlOutFileExpr(SQLExpr_ptr file)
{
  this->file = file;
}

// @Override
void MySqlOutFileExpr::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlOutFileExpr)))
  {
    acceptChild(visitor, file);
  }
  visitor->endVisit(SharedObject(MySqlOutFileExpr));
}

// @Override
SQLObject_list_ptr MySqlOutFileExpr::getChildren()
{
  SQLObject_list_ptr tmp = std::make_shared<std::list<SQLObject_ptr>>();
  tmp->push_back(file);
  return tmp;
}

SQLExpr_ptr MySqlOutFileExpr::getFile()
{
  return file;
}

void MySqlOutFileExpr::setFile(SQLExpr_ptr file)
{
  this->file = file;
}

string_ptr MySqlOutFileExpr::getCharset()
{
  return charset;
}

void MySqlOutFileExpr::setCharset(string_ptr charset)
{
  this->charset = charset;
}

SQLExpr_ptr MySqlOutFileExpr::getColumnsTerminatedBy()
{
  return columnsTerminatedBy;
}

void MySqlOutFileExpr::setColumnsTerminatedBy(SQLExpr_ptr columnsTerminatedBy)
{
  this->columnsTerminatedBy = columnsTerminatedBy;
}

BOOL_ptr MySqlOutFileExpr::isColumnsEnclosedOptionally()
{
  return columnsEnclosedOptionally;
}

void MySqlOutFileExpr::setColumnsEnclosedOptionally(BOOL_ptr columnsEnclosedOptionally)
{
  this->columnsEnclosedOptionally = columnsEnclosedOptionally;
}

SQLLiteralExpr_ptr MySqlOutFileExpr::getColumnsEnclosedBy()
{
  return columnsEnclosedBy;
}

void MySqlOutFileExpr::setColumnsEnclosedBy(SQLLiteralExpr_ptr columnsEnclosedBy)
{
  this->columnsEnclosedBy = columnsEnclosedBy;
}

SQLLiteralExpr_ptr MySqlOutFileExpr::getColumnsEscaped()
{
  return columnsEscaped;
}

void MySqlOutFileExpr::setColumnsEscaped(SQLLiteralExpr_ptr columnsEscaped)
{
  this->columnsEscaped = columnsEscaped;
}

SQLLiteralExpr_ptr MySqlOutFileExpr::getLinesStartingBy()
{
  return linesStartingBy;
}

void MySqlOutFileExpr::setLinesStartingBy(SQLLiteralExpr_ptr linesStartingBy)
{
  this->linesStartingBy = linesStartingBy;
}

SQLLiteralExpr_ptr MySqlOutFileExpr::getLinesTerminatedBy()
{
  return linesTerminatedBy;
}

void MySqlOutFileExpr::setLinesTerminatedBy(SQLLiteralExpr_ptr linesTerminatedBy)
{
  this->linesTerminatedBy = linesTerminatedBy;
}

SQLExpr_ptr MySqlOutFileExpr::getIgnoreLinesNumber()
{
  return ignoreLinesNumber;
}

void MySqlOutFileExpr::setIgnoreLinesNumber(SQLExpr_ptr ignoreLinesNumber)
{
  this->ignoreLinesNumber = ignoreLinesNumber;
}

SQLObject_ptr MySqlOutFileExpr::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<MySqlOutFileExpr>(new MySqlOutFileExpr());
  std::shared_ptr<MySqlOutFileExpr> x = std::dynamic_pointer_cast<MySqlOutFileExpr>(clone_tmp);
  // MySqlOutFileExpr x = new MySqlOutFileExpr();

  if (file != nullptr)
  {
    x->setFile(std::dynamic_pointer_cast<SQLExpr>(file->clone()));
  }

  x->charset = charset;

  if (columnsTerminatedBy != nullptr)
  {
    x->setColumnsTerminatedBy(std::dynamic_pointer_cast<SQLExpr>(columnsTerminatedBy->clone()));
  }

  x->columnsEnclosedOptionally = columnsEnclosedOptionally;

  if (columnsEnclosedBy != nullptr)
  {
    x->setColumnsEnclosedBy(std::dynamic_pointer_cast<SQLLiteralExpr>(columnsEnclosedBy->clone()));
  }

  if (columnsEscaped != nullptr)
  {
    x->setColumnsEscaped(std::dynamic_pointer_cast<SQLLiteralExpr>(columnsEscaped->clone()));
  }

  if (linesStartingBy != nullptr)
  {
    x->setLinesStartingBy(std::dynamic_pointer_cast<SQLLiteralExpr>(linesStartingBy->clone()));
  }

  if (linesTerminatedBy != nullptr)
  {
    x->setLinesTerminatedBy(std::dynamic_pointer_cast<SQLLiteralExpr>(linesTerminatedBy->clone()));
  }

  if (ignoreLinesNumber != nullptr)
  {
    x->setIgnoreLinesNumber(std::dynamic_pointer_cast<SQLExpr>(ignoreLinesNumber->clone()));
  }

  return x;
}
